from django.db import models
from django.utils import timezone

class PromptCategory(models.Model):
    name = models.CharField(max_length=100, verbose_name="分类名称")
    description = models.TextField(blank=True, verbose_name="分类描述")
    created_at = models.DateTimeField(default=timezone.now, verbose_name="创建时间")

    class Meta:
        verbose_name = "提示词分类"
        verbose_name_plural = verbose_name

    def __str__(self):
        return self.name

class Prompt(models.Model):
    title = models.CharField(max_length=200, verbose_name="标题")
    content = models.TextField(verbose_name="提示词内容")
    category = models.ForeignKey(PromptCategory, on_delete=models.CASCADE, verbose_name="所属分类")
    description = models.TextField(blank=True, verbose_name="描述")
    created_at = models.DateTimeField(default=timezone.now, verbose_name="创建时间")
    updated_at = models.DateTimeField(auto_now=True, verbose_name="更新时间")

    class Meta:
        verbose_name = "提示词"
        verbose_name_plural = verbose_name
        ordering = ['-updated_at']

    def __str__(self):
        return self.title
